# function
close_pro() {
  local local_port=$1
  # 使用 lsof 查询端口pid
  pids=$(lsof -i :$local_port | awk 'NR>1 {print $2}')
  # 有
  if [ -n "$pids" ]; then
      for pid in $pids; do
        close_PID_pro $pid
      done
  else
    echo "No found PID on port $local_port ."
  fi
}

close_PID_pro() {
  local pid_to_kill=$1
  kill -15 $pid_to_kill
  echo "close ok. PID: $pid"
}


# 检查是否提供了端口号
if [ $# -ne 1 ]; then
    echo "No port: $0 <port>. using default 7037"
    close_pro 7037
    exit 1
else
  port=$1
  close_pro $port
fi



